package com.woniuxy.service.impl;

import com.woniuxy.dao.PropertyMapper;
import com.woniuxy.dao.VendorMapper;
import com.woniuxy.dto.ResultServiceIn;
import com.woniuxy.pojo.Property;
import com.woniuxy.pojo.Users;
import com.woniuxy.pojo.Vendor;
import com.woniuxy.service.PropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PropertyServiceImpl implements PropertyService {

    @Autowired
    private PropertyMapper propertyMapper;

    //根据账号查找密码
    @Override
    public Property findProByAccount(String account) {
        return propertyMapper.findProByAccount(account);
    }

    @Override
    public void insertProperty(Property v) {
        propertyMapper.saveProResultVid(v);
    }

    @Override
    public void updateProperty(Property property) {
        propertyMapper.updateByPrimaryKeySelective(property);
    }


    @Override
    public Property findProById(Long pid) {
        return propertyMapper.selectByPid(pid);
    }

    //修改密码
    @Override
    public void updatePassById(Long id, String newPass) {
        propertyMapper.updatePassById(id,newPass);
    }

    //查询已入驻的服务和正在审核中的服务
    @Override
    public List<ResultServiceIn> findServiceIn(Long id) {
        return propertyMapper.findServiceIn(id);
    }

    //删除已入驻的服务
    @Override
    public void delServiceIn(Long id, Long smid) {
        propertyMapper.delServiceIn(id,smid);
    }

    //物业修改服务价格
    @Override
    public void updateServerPrice(Long id, Long smid, Double price) {
        propertyMapper.updateServerPrice(id,smid,price);
    }

    //查询可入驻的服务信息
    @Override
    public List<ResultServiceIn> canBeIn(Long id) {
        return propertyMapper.canBeIn(id);
    }

    //物业进行服务入驻
    @Override
    public void oneServiceIn(Long id, Long smid, Double price) {
        propertyMapper.oneServiceIn(id,smid,price,new Date());
    }

    //业主管理数据
    @Override
    public List<Users> ownerList(Long id) {

        return  propertyMapper.ownerList(id);
    }

    //物业修改用户登录状态（限制登录）
    @Override
    public void checkUserStatus(Long id, Integer status) {
        propertyMapper.checkUserStatus(id,status);
    }
}
